﻿using Enyim.Caching.Memcached;
using Sportsbook.CouchbasePersistence.CouchbaseClients;
using Sportsbook.CouchbasePersistence.Models.BetSlips;
using Sportsbook.Domain.Models.BetSlips;
using Sportsbook.Domain.Repositories;

namespace Sportsbook.CouchbasePersistence.Repositories
{
    public class BetSlipsRepository : IBetSlipsRepository
    {
        private readonly SportsbookClient client;

        public BetSlipsRepository(SportsbookClient client)
        {
            this.client = client;
        }

        public IBetSlip Get(string customerId)
        {
            //var betSlip = new BetSlip();
            //betSlip.Tickets = new List<ITicket>() { 
            //new Ticket(){Price = 120},
            //new Ticket(){Price = 120}
            //};
            //Save(betSlip, customerId);

            return client.GetJson<BetSlip>("bet-slip/" + customerId);
        }
        public void Save(IBetSlip model, string customerId)
        {
            var key = "bet-slip/" + customerId;
            client.StoreJson(StoreMode.Set, key, model);
        }
    }
}
